package flc.ast;

import android.graphics.Color;
import android.view.View;

import androidx.annotation.NonNull;

import java.util.ArrayList;
import java.util.List;

import flc.ast.databinding.ActivityHomeBinding;
import flc.ast.fragment.EquipmentFragment;
import flc.ast.fragment.HomeFragment;
import flc.ast.fragment.MyFragment;
import flc.ast.fragment.TacticFragment;
import stark.common.basic.base.BaseNoModelActivity;
import stark.common.basic.base.BaseTabFragmentHomeActivity;
import stark.common.basic.base.DefExitAppDialog;
import stark.common.basic.event.EventStatConstant;
import stark.common.basic.event.EventStatProxy;

public class HomeActivity extends BaseTabFragmentHomeActivity<ActivityHomeBinding> implements View.OnClickListener {

    @Override
    protected int getPageType() {
        return EventStatConstant.PAGE_TAB_HOME;
    }

    @Override
    protected void initView() {
        super.initView();
        EventStatProxy.getInstance().statLaunch(this);
    }

    @NonNull
    @Override
    protected List<BaseTabFragmentHomeActivity<ActivityHomeBinding>.FragmentViewBinder> getFragmentViewBinders() {
        List<FragmentViewBinder> list = new ArrayList<>();
        list.add(new FragmentViewBinder(HomeFragment.class, R.id.llHome));
        list.add(new FragmentViewBinder(TacticFragment.class, R.id.llTactic));
        list.add(new FragmentViewBinder(EquipmentFragment.class, R.id.llEquipment));
        list.add(new FragmentViewBinder(MyFragment.class, R.id.llMy));
        return list;
    }

    @Override
    protected void onFragmentViewClick(View view) {
        clearSelection();
        switch (view.getId()) {
            case R.id.llHome:
                mDataBinding.ivHome.setImageResource(R.drawable.tab1);
                mDataBinding.tvHome.setTextColor(Color.parseColor("#01B4FE"));
                break;
            case R.id.llTactic:
                mDataBinding.ivTactic.setImageResource(R.drawable.tab2);
                mDataBinding.tvTactic.setTextColor(Color.parseColor("#01B4FE"));
                break;
            case R.id.llEquipment:
                mDataBinding.ivEquipment.setImageResource(R.drawable.tab3);
                mDataBinding.tvEquipment.setTextColor(Color.parseColor("#01B4FE"));
                break;
            case R.id.llMy:
                mDataBinding.ivMy.setImageResource(R.drawable.tab4);
                mDataBinding.tvMy.setTextColor(Color.parseColor("#01B4FE"));
                break;
        }
    }

    @Override
    protected int getFragmentContainerId() {
        return R.id.flHome;
    }

    @Override
    protected int onCreate() {
        return R.layout.activity_home;
    }

    private void clearSelection() {
        mDataBinding.ivHome.setImageResource(R.drawable.tab11);
        mDataBinding.tvHome.setTextColor(Color.parseColor("#8001B4FE"));
        mDataBinding.ivTactic.setImageResource(R.drawable.tab22);
        mDataBinding.tvTactic.setTextColor(Color.parseColor("#8001B4FE"));
        mDataBinding.ivEquipment.setImageResource(R.drawable.tab33);
        mDataBinding.tvEquipment.setTextColor(Color.parseColor("#8001B4FE"));
        mDataBinding.ivMy.setImageResource(R.drawable.tab44);
        mDataBinding.tvMy.setTextColor(Color.parseColor("#8001B4FE"));
    }

}